#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
using namespace std;
class Solution {


public:
    void swap(string& s, size_t begin, size_t end) {
        while (begin < end) {
            char tem = s[begin];
            s[begin] = s[end];
            s[end] = tem;
            begin++;
            end--;
        }
    }
    string reverseStr(string s, int k) {
        size_t i = 0;
        for (i = 0; i < s.size(); i += 2 * k) {
            if (i + k - 1 >= s.size())break;
            swap(s, i, i + k - 1);
        }
        if (i < s.size() && s.size() - i < k) {
            swap(s, i, s.size() - 1);
        }
        return s;
    }
};
int main() {
    string s1("abcdefg");
    Solution ss;
    ss.reverseStr(s1, 3);
    cout << s1 << endl;

}